package com.mgfireworks.mgplatform.mgadmin.user;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import cn.hn.java.summer.annotation.ParamValid;

import com.mgfireworks.mgplatform.mgadmin.user.model.RoleFunction;

/**
 * 
 * @author nap
 * 20161015-10:19:48
 * 角色功能控制器
 */
@Controller
@RequestMapping("/user/rolefunction")
public class RoleFunctionController {

	@Autowired
	RoleFunctionService rolefunctionService;
	
	/**
	 * 角色功能列表
	 * @return
	 */
	@RequestMapping("/list")
	public List<RoleFunction> list(RoleFunction p){
		return rolefunctionService.getRoleFunctions(p);
	}

	/**
	 * 添加角色功能
	 */
	@RequestMapping(value="/add",method=RequestMethod.GET)
	public void add(){
	}
	
	/**
	 * 提交添加角色功能
	 */
	@RequestMapping(value="/add",method=RequestMethod.POST)
	public void postAdd(@ParamValid RoleFunction p){
		rolefunctionService.addRoleFunction(p);
	}

	/**
	 * 编辑角色功能
	 */
	@RequestMapping(value="/edit",method=RequestMethod.GET)
	public RoleFunction edit(RoleFunction p){
		return rolefunctionService.getRoleFunction(p);
	}
	
	/**
	 * 提交编辑角色功能
	 */
	@RequestMapping(value="/edit",method=RequestMethod.POST)
	public void postEdit(@ParamValid RoleFunction p){
		rolefunctionService.editRoleFunction(p);
	}
	
	/**
	 * 获取角色功能
	 */
	@RequestMapping(value="/get",method=RequestMethod.GET)
	public RoleFunction get(RoleFunction p){
		return rolefunctionService.getRoleFunction(p);
	}
	
	/**
	 * 删除角色功能
	 */
	@RequestMapping("/del")
	public void del(RoleFunction p){
		rolefunctionService.delRoleFunction(p);
	}
}